package com.swh.cloud.biz.ui.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.swh.cloud.biz.ui.action.UserServer;
import com.swh.cloud.biz.ui.conf.BIZServerLBConfig;
import com.swh.user.domain.UserEntity;

/**
 * 此类包装了对服务的访问处理
 * 用户直接访问该层（可加一些调用前的校验,提高请求的有效性）
 * @author sangwenhao
 * @date 2016年12月23日
 */
@RestController
@RequestMapping(value="/userAction")
public class UserController {
    
    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserServer userServer ;
    
    @RequestMapping("/")
    private String isStart(){
	return "user-cloud-biz-ui is start Success" ;
    }
    
    @RequestMapping("/getUserInfo/{id}")
    public ResponseEntity<UserEntity> getUserInfo(@PathVariable(value="id") Long id){
	logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>getUserInfo");
	UserEntity users = userServer.getUserInfo(id);
	return new ResponseEntity<UserEntity>(users,HttpStatus.OK) ;
    }
    
    @RequestMapping("/getUserByUnion")
    public ResponseEntity<List<UserEntity>> getUserByUnion(){
	logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>getUserByUnion");
	Map<String, UserEntity> map = new HashMap<String, UserEntity>();
	List<UserEntity> users = userServer.getUserByUnion(map);
	return new ResponseEntity<List<UserEntity>>(users,HttpStatus.OK) ;
    }
    
}
